<div class="page-add-new-article">
    <div id="content-header">
        <h1>List Node Types</h1>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
        <?php
            echo $this->Form->create('NodeType', array('id' => 'paginate','class'=>'form-horizontal', 'action' => 'edit', 'url' => $this->request->here(false), 'type' => 'post',
                'inputDefaults' => array('label' => false, 'format' => array('before', 'label', 'between', 'input', 'after', 'error'))));
            echo $this->element('toolbar');
        ?>									
        
            <?php   
                $fieldsets['name'] = $this->Form->input('name', array(
                    'label' => array('text'=>__d('system','Name'),'class' => 'control-label'),
                    'between' => '<div class="controls">',
                    'div' => array('class' => 'control-group'),
                    'after' => '</div>',
                    'type' => 'text'));
                $fieldsets['enabled'] = $this->Form->input('enabled', array(
                    'label' => array('text'=>__d('system','Menu Backend'),'class' => 'control-label'),
                    'between' => '<div class="controls">',
                    'div' => array('class' => 'control-group'),                    
                    'after' => '</div>',
                    'type' => 'checkbox'));
                $fieldsets['set_menu'] = $this->Form->input('set_menu', array(
                    'label' => array('text'=>__d('system','Show is menu'),'class' => 'control-label'),        
                    'between' => '<div class="controls">',
                    'div' => array('class' => 'control-group'),
                    'default'=>0, 
                    'class'=>'set_menu',                   
                    'after' => '</div>',
                    'type' => 'checkbox'));                
                $fieldsets['allow_share'] = $this->Form->input('allow_share', array(
                    'label' => array('text'=>__d('system','Allow Share'),'class' => 'control-label'),        
                    'between' => '<div class="controls">',
                    'div' => array('class' => 'control-group'),
                    'default'=>0,                                            
                    'after' => '</div>',
                    'type' => 'checkbox'));
                $fieldsets['menu_child'] = $this->Form->input('menu_child', array(
                    'label' => array('text'=>'Sub Menu','class' => 'control-label'),        
                    'between' => '<div class="controls">',
                    'div' => array('class' => 'control-group'),
                    'default'=>0, 
                    'class'=>'set_menu',                                 
                    'after' => '</div>',
                    'type' => 'checkbox'));                                          
                $fieldsets['set_image'] = $this->Form->input('set_image', array(
                    'label' => array('text'=>__d('system','Show image'),'class' => 'control-label'),        
                    'between' => '<div class="controls">',
                    'div' => array('class' => 'control-group'),        
                    'after' => '</div>',
                    'type' => 'checkbox'));
                $fieldsets['description'] = $this->Form->input('description', array(
                    'label' => array('text'=>__d('system','Description'),'class' => 'control-label'),
                    'between' => '<div class="controls">',
                    'div' => array('class' => 'control-group'),
                    'after' => '</div>',
                    'type' => 'textarea'));               
                $fieldsets['image'] = $this->Form->input('image', array(
                    'label' => array('text'=>__d('system','Image'),'class' => 'control-label'),
                    'between' => '<div class="controls">',
                    'div' => array('class' => 'control-group'),
                    'after' => '</div>',
                    'type' => 'file'));                      

            ?>    
            <?php
                echo $this->Layout->form($_layouts, $fieldsets);
            ?>
            <div class="widget-box widget-content-no-padding">        
            <div class="control-group">
                <label for="NodeFieldProjectImage" class="control-label"><?php echo __d("system", "Image Relation")?></label>            
                <div class="controls">
                    <?php echo $this->Form->input('ProImage', array(
                        'label' => false,
                        'type'  => 'file', 
                        'name' => 'data[ProImage][]'));?>
                </div>
                <div id="cloneImage"></div>
                <a style="padding-left: 200px;padding-bottom: 10px; clear: both; display: block;" href="javascript:add_more();"><?php echo __d("system", "Add more image")?></a>
            </div>   
            </div>             
        
        <!--List Field-->
        
        <!--End-->
        <?php
            echo $this->Form->hidden('Paginate.task', array('id' => 'task', 'value' => ''));
            echo $this->Form->end();
        ?>        								
    </div>	
</div>
</div>
<script type="text/javascript">
    jQuery(document).ready(function($){
        $('<span>Size: 1600x850</span>').insertAfter("#NodeFieldBackgroundImage");
        $('<span>Enter a valid number: (int)</span>').insertAfter("#NodeFieldBackgroundPiority");
        /*$('#NodeFieldNewPostDate').datetimepicker({
            dateFormat: 'yy-mm-dd',
            timeFormat: 'hh:mm'
        });*/
    });
    function add_more(){
        var element= jQuery("#cloneImage").prev();
        jQuery(element).clone().insertBefore("#cloneImage");
        var $this = Green.Elfinder;
        jQuery('form input.file-upload').prop('readonly' , true).click(function(){
            $this.show(jQuery(this));
        });
    }
    function delete_image(id){
        if (confirm("Are you sure you want to delete?")) {
            var href= "<?php echo '/node/node/delete_image/'?>"+id;
            jQuery.ajax({
                url: href,
                type: "GET",
                success: function(data) {
                    jQuery('#image_'+id).remove();
                    jQuery('#image_del_'+id).remove();           
                }
            });
        }
    }
</script>